package wa.jdk14logging;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;

public class LogFormatter 
extends Formatter
{
	private static Date date = new Date();
	private static DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
	private boolean flatMode=false;
	
	public String format(LogRecord record)
	{
		String fmt="";
		date.setTime(record.getMillis());
		if (flatMode)
			fmt = record.getMessage()+"\n";
		else
			fmt = dateFormat.format(date) + " [" + record.getLevel() + "]\t"+ record.getMessage() + "\n";
		return fmt;
	}
	/**
	 * @return Returns the flatMode.
	 */
	public boolean isFlatMode() {
		return flatMode;
	}
	/**
	 * @param flatMode The flatMode to set.
	 */
	public void setFlatMode(boolean flatMode) {
		this.flatMode = flatMode;
	}
}